-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ota: fix potential network error by checking return values #4054
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? No Sign in to your account
Conversation
I don't know how to check this. I don't really understand the involved code. |
@@ -307,7 +307,7 @@ void ArduinoOTAClass::_runUpdate() { | |||
int waited = 1000; | |||
while (!client.available() && waited--) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a PolledTimeout, now that they exist...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original code looks very cut-n-pastey. Love the update's brevity.
cores/esp8266/Updater.h
Outdated
// load exactly one _bufSize before flashing it | ||
// (the last one may be smaller) | ||
size_t wantedBufSize = remaining() < _bufferSize? | ||
remaining(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of odd multiline trinary. Style related only. Logic seems fine.
size_t readThisTime = 0; | ||
|
||
while (data.available() && _bufferLen < wantedBufSize) { | ||
size_t got = data.read(_buffer + _bufferLen, wantedBufSize - _bufferLen); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to check for if (!got) return fail;
due to something weird on the connection side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semantic ensures data.read()>0
because data.available()
is true, but adding a test just in case.
There is no constraint on number of bytes read, nor duration / timeout.
superseded by #6369 |
This needs further testing and is not needed for 2.4.0.